package xyz.yuzegod.megawalls.classes.normal.hunter;

import org.bukkit.Sound;
import org.bukkit.entity.Player;
import xyz.yuzegod.megawalls.classes.Classes;
import xyz.yuzegod.megawalls.classes.Skill;
import xyz.yuzegod.megawalls.game.GamePlayer;
import xyz.yuzegod.megawalls.stats.KitStatsContainer;

import java.util.ArrayList;
import java.util.List;

public class MainSkill extends Skill
{
    public MainSkill(final Classes classes) {
        super("鹰眼", classes);
    }
    
    @Override
    public int maxedLevel() {
        return 5;
    }
    
    @Override
    public double getAttribute(final int level) {
        switch (level) {
            case 1: {
                return 7.6;
            }
            case 2: {
                return 9.2;
            }
            case 3: {
                return 10.8;
            }
            case 4: {
                return 12.4;
            }
            case 5: {
                return 14.0;
            }
            default: {
                return 7.6;
            }
        }
    }
    
    @Override
    public List<String> getInfo(final int level) {
        final List<String> lore = new ArrayList<String>();
        if (level == 1) {
            lore.add(" §8▪ §7为拉满的弓箭附加追踪效果,持续§a" + this.getAttribute(level) + "§7秒。");
            lore.add("   §7每次命中恢复0.5血量,但不会增加能量。");
            return lore;
        }
        lore.add(" §8▪ §7为拉满的弓箭附加追踪效果,持续§8" + this.getAttribute(level - 1) + " ➜ §a" + this.getAttribute(level) + "§7秒。");
        lore.add("   §7每次命中恢复0.5血量,但不会增加能量。");
        return lore;
    }
    
    @Override
    public void upgrade(final GamePlayer gamePlayer) {
        final KitStatsContainer kitStats = gamePlayer.getPlayerStats().getKitStats(this.getClasses());
        kitStats.addSkillLevel();
    }
    
    @Override
    public int getPlayerLevel(final GamePlayer gamePlayer) {
        return gamePlayer.getPlayerStats().getKitStats(this.getClasses()).getSkillLevel();
    }
    
    @Override
    public boolean use(final GamePlayer gamePlayer, final KitStatsContainer kitStats) {
        final Player player = gamePlayer.getPlayer();
        if (Hunter.skill.getOrDefault(gamePlayer, 0) > 0) {
            player.sendMessage("§c技能正在冷却中！");
            return false;
        }
        gamePlayer.playSound(Sound.ORB_PICKUP, 1.0f, 1.0f);
        Hunter.skill.put(gamePlayer, (int)this.getAttribute(this.getPlayerLevel(gamePlayer)));
        return true;
    }
    
    @Override
    public String getSkillTip(final GamePlayer gamePlayer) {
        return this.getClasses().getNameColor() + "§l" + this.getName() + " " + ((Hunter.skill.getOrDefault(gamePlayer, 0) == 0) ? ((gamePlayer.getEnergy() == 100) ? "§a§l✓" : "§c§l✕") : ("§e§l" + Hunter.skill.get(gamePlayer)));
    }
}
